<template>
    <div class="app-detail">
        <list-layout>
         <div slot="search">
            <el-form :model="queryParams" :inline="true" ref="queryForm" v-show="showSearch" label-width="128px">
                <el-form-item :label="$t('extraCoa.materialCode')">
                    <el-input v-model="queryParams.matnr" :placeholder="$t('public.placeholder',{placeholder: $t('extraCoa.materialCode')})" clearable size="small" @keyup.enter.native="handleQuery" />
                </el-form-item>
                <el-form-item :label="$t('extraCoa.ebeln')">
                    <el-input v-model="queryParams.ebeln" :placeholder="$t('public.placeholder',{placeholder: $t('extraCoa.ebeln')})" clearable size="small" @keyup.enter.native="handleQuery" />
                </el-form-item>
                <el-form-item :label="$t('extraCoa.supplierCode')">
                    <el-input v-model="queryParams.lifnr" :placeholder="$t('public.placeholder',{placeholder: $t('extraCoa.supplierCode')})" clearable size="small" @keyup.enter.native="handleQuery" />
                </el-form-item>
                <el-form-item :label="$t('extraCoa.supplierName')">
                    <el-input v-model="queryParams.name1" :placeholder="$t('public.placeholder',{placeholder: $t('extraCoa.supplierName')})" clearable size="small" @keyup.enter.native="handleQuery" />
                </el-form-item>
                <el-form-item :label="$t('extraCoa.beginTime')">
                    <el-date-picker v-model="queryParams.beginTime" value-format="yyyy-MM-dd" type="date" :placeholder="$t('public.select_holder',{select_holder: $t('extraCoa.beginTime')})">
                    </el-date-picker>
                </el-form-item>
                <el-form-item :label="$t('extraCoa.endTime')">
                    <el-date-picker v-model="queryParams.endTime" value-format="yyyy-MM-dd" type="date" :placeholder="$t('public.select_holder',{select_holder: $t('extraCoa.endTime')})">
                    </el-date-picker>
                </el-form-item>
            </el-form>
            <div style="display: flex; justify-content: center;margin-top: 10px;">
                <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">{{ $t("public.search") }}</el-button>
                <el-button icon="el-icon-refresh" class="resectBtn" size="mini" @click="resetQuery">{{ $t("public.reset") }}</el-button>
            </div>
        </div>

        <div class="app-container">

            <!-- <el-row :gutter="10" class="mb8 btnGroup">
                <el-col :span="1.5">
                    <el-button size="mini" type="primary" :disabled="ids.length!=1"
                    icon="el-icon-s-check"  @click="typeOpen=true">  {{ "一次试投审批" }}</el-button>
                </el-col>
                <el-col :span="1.5">
                    <el-button size="mini" type="primary" :disabled="ids.length!=1"
                     icon="el-icon-s-check" @click="typeOpen2=true">  {{ "二次试投审批" }}</el-button>
                </el-col>
            </el-row>  -->
            <div class="container-table">
                <el-table class="table-fixed"   ref="multipleTable" :key="incomingKey" v-loading="loading" :height="tableHeight" border
                :data="incomingList"  @selection-change="handleSelectionChange" >
                    <!-- <el-table-column type="selection" width="55" fixed="left" align="center" :show-overflow-tooltip="true" /> -->
                    <el-table-column :label="$t('extraCoa.deliveryNoteNumber')" sortable  align="left" prop="zsrmno" min-width="120" :show-overflow-tooltip="true" />
                    <el-table-column :label="$t('extraCoa.supplierCode')" sortable  align="left" prop="lifnr" min-width="120" :show-overflow-tooltip="true" />
                    <el-table-column :label="$t('extraCoa.supplierName')" sortable  align="left" prop="name1" min-width="120" :show-overflow-tooltip="true" />
                    <el-table-column :label="$t('extraCoa.status')" sortable  align="left" prop="status" min-width="120" :show-overflow-tooltip="true" >
                      <template slot-scope="scope">
                        <div class="action-wrap">
                          <span v-if="parseInt(scope.row.status) === 0" class="labelB">未处理</span>
                          <span v-if="parseInt(scope.row.status) === 1" class="labelY">已处理</span>
                        </div>
                      </template>
                    </el-table-column>
                    <el-table-column :label="$t('extraCoa.deliveryDate')" sortable  align="left" prop="lfdat" min-width="120" :show-overflow-tooltip="true" />
                    <el-table-column :label="$t('extraCoa.shippingContact')" sortable  align="left" prop="contact" min-width="120" :show-overflow-tooltip="true" />
                    <el-table-column :label="$t('extraCoa.shippingContactInformation')" sortable  align="left" prop="telNumber" min-width="120" :show-overflow-tooltip="true" />
                    <el-table-column :label="$t('extraCoa.transportationMethod')" sortable  align="left" prop="traty" min-width="120" :show-overflow-tooltip="true" />
                    <el-table-column :label="$t('extraCoa.transportVehicleNumberShipNumber')" sortable  align="left" prop="traid" min-width="120" :show-overflow-tooltip="true" />
                    <el-table-column :label="$t('extraCoa.shippingContact2')" sortable  align="zzreceiver" prop="lichn" min-width="120" :show-overflow-tooltip="true" />
                    <el-table-column :label="$t('extraCoa.deliveryContactInformation')" sortable  align="left" prop="zzreceivcall" min-width="120" :show-overflow-tooltip="true" />
                    <el-table-column :label="$t('extraCoa.purchaseOrder')" sortable  align="left" prop="ebeln" min-width="120" :show-overflow-tooltip="true" />
                    <el-table-column :label="$t('extraCoa.purchaseOrderNumber')" sortable  align="left" prop="ebelp" min-width="120" :show-overflow-tooltip="true" />
                    <el-table-column :label="$t('extraCoa.materialCode')" sortable  align="left" prop="matnr" min-width="120" :show-overflow-tooltip="true" />
                    <el-table-column :label="$t('extraCoa.quantity')" sortable  align="left" prop="lfimg" min-width="120" :show-overflow-tooltip="true" />
                    <el-table-column :label="$t('extraCoa.coaFile')" sortable  align="left" prop="coaFile" min-width="120" :show-overflow-tooltip="true" />
                    <el-table-column :label="$t('extraCoa.zbjrq')" sortable  align="left" prop="zbjrq" min-width="120" :show-overflow-tooltip="true" />
                </el-table>

                <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" @pagination="getList" layout="total, sizes, prev, pager, next, jumper" />
            </div>

        </div>
        </list-layout>
        <!-- 查看 -->
        <!-- <el-dialog :title="$t('public.detail')" :visible.sync="typeOpen3" center top="11vh"  width="1000px" :fullscreen="fullscreen" @close="close">
            <el-form :model="typeModel" size="small" label-suffix=":" ref="typeModel"   label-width="108px">
                <el-row :gutter="24" class="dia">
                    <el-col :span="24">
                        <el-divider content-position="center">{{ $t('trialinvestment.Onceary')}}  </el-divider>
                    </el-col>
                    <el-col :span="24">
                        <el-form-item :label="$t('trialinvestment.oneResults')" prop="onceTrialResult">
                            <el-radio-group v-model="typeModel.onceTrialResult" class="smallRadio" disabled>
                                <el-radio :label="'0'"> 不通过 </el-radio>
                                <el-radio :label="'1'"> 通过 </el-radio>
                            </el-radio-group>
                        </el-form-item>
                    </el-col>
                    <el-col :span="24">
                        <el-form-item :label="$t('trialinvestment.oneResultsfile')" prop="onceTrialDoc" style="width:100%">
                            <file-upload :limit="1" bizType="onceTrialDoc" :otherList="onceTrialDocFile" :bizId="typeModel.id" disabled
                            v-model="typeModel.onceTrialDoc" @change="(fileList)=>picChange(fileList,'onceTrialDoc')"></file-upload>
                        </el-form-item>
                    </el-col>

                    <el-col :span="24">
                        <el-form-item :label="$t('rule.remark')" prop="auditRemark">
                            <el-input size="small" type="textarea" :autosize="{ minRows: 5, maxRows: 6 }" disabled
                            v-model="typeModel.onceRemark" maxlength="1000">
                            </el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="24" v-if="typeModel.onceTrialResult==0">
                        <el-form-item  :label="$t('trialinvestment.secondtrial')" prop="twiceTrial" >
                            <el-radio-group v-model="typeModel.twiceTrial" class="smallRadio" disabled>
                                <el-radio :label="'0'"> 否 </el-radio>
                                <el-radio :label="'1'"> 是 </el-radio>
                            </el-radio-group>
                        </el-form-item>
                    </el-col>
                    <el-col :span="24" v-if="typeModel.twiceTrial==1 && typeModel.twiceTrialResult">
                        <el-divider content-position="center">
                            {{ $t('trialinvestment.Secondary')}}
                            <el-tooltip class="item" effect="dark" :content="$t('trialinvestment.Secondary')" placement="right">
                                    <i class="el-icon-question" style="font-size:16px;cursor:pointer"></i>
                            </el-tooltip>
                        </el-divider>
                    </el-col>

                    <el-col :span="24" v-if="typeModel.twiceTrial==1 && typeModel.twiceTrialResult">
                        <el-form-item :label="$t('trialinvestment.Secondresults')" prop="twiceTrialResult" >
                            <el-radio-group v-model="typeModel.twiceTrialResult" class="smallRadio" disabled>
                                <el-radio :label="'0'"> 不通过 </el-radio>
                                <el-radio :label="'1'"> 通过 </el-radio>
                            </el-radio-group>
                        </el-form-item>
                    </el-col>

                    <el-col :span="24" v-if="typeModel.twiceTrial==1 && typeModel.twiceTrialResult">
                        <el-form-item :label="$t('trialinvestment.secondResultsfile')" prop="twiceTrialDoc" style="width:100%">
                            <file-upload :limit="1" bizType="twiceTrialDoc" :otherList="twiceTrialDocFile" :bizId="typeModel.id" disabled
                            v-model="typeModel.twiceTrialDoc" @change="(fileList)=>picChange(fileList,'twiceTrialDoc')"></file-upload>

                        </el-form-item>
                    </el-col>
                    <el-col :span="24" v-if="typeModel.twiceTrial==1 && typeModel.twiceTrialResult">
                        <el-form-item :label="$t('rule.remark')" prop="remark">
                            <el-input size="small" type="textarea" :autosize="{ minRows: 5, maxRows: 6 }" v-model="typeModel.twiceRemark"
                             maxlength="1000" disabled>
                            </el-input>
                        </el-form-item>
                    </el-col>

                </el-row>

            </el-form>

        </el-dialog> -->

    </div>
</template>

<script>

import {mapGetters, mapState} from 'vuex'

import SelectUserDialog from '@/views/components/SelectUserDialog'
import { geFileByBiz } from '@/api/file/file'

import { listExtraCoaAPI,selectoneAPI} from "@/api/inventoryManagement/extraCoa"

export default {
    name: 'editMaterial',
    dicts: [
       'NYIQC_CYCLE_TYPE',
       'NYIQC_RULE_TACTICS'
    ],
    components: {

        SelectUserDialog,
    },
    data() {

        return {
            showSearch: true,
            tableHeight: 'calc(100vh - 308px)',

            typeOpen: false,
            queryParams:{
                pageNum:1,
                pageSize:20
            },
            twiceTrial:"1",
            onceTrialDocFile:[],
            twiceTrialDocFile:[],
            // 遮罩层
            loading: true,
            // 选中数组
            ids: [],
            // 非单个禁用
            single: true,
            // 非多个禁用
            multiple: true,
            // 显示搜索条件
            showSearch: true,
            stemList: [],
            // 总条数
            total: 0,
            // 字典表格数据
            incomingList: [],
            // 弹出层标题
            title: '',
            // 是否显示弹出层
            open: false,
            // 日期范围
            dateRange: [],
            selectRows: [],
            rowifInspect: '',
            // 查询参数

            // 表单参数
            form: {},
            // 表单校验
            fullscreen: false,
            incomingKey: 0,
            projectList:[],
            ruleData: {},   // 规则详情
            fileList:[],
            ids:[],
            disabled:false,
            typeOpen2:false,
            typeOpen3:false,
            twotype:"",
            typeModel:{}
        }
    },

    mounted() {
        // this.getRuleInfo()
        this.getList()

    },
    activated() {
        // this.getRuleInfo()
        this.getList()
    },
    filters:{
        timefilter(time){
            if(!time){
                return ""
            }
            var date = new Date(time);
            var Y = date.getFullYear() + '-';
            var M = (date.getMonth()+1 < 10 ? '0'+(date.getMonth()+1) : date.getMonth()+1) + '-';
            var D = date.getDate() + ' ';
            var h = (date.getHours() < 10 ?  '0'+date.getHours() : date.getHours() ) + ':';
            var m = (date.getMinutes() < 10 ?  '0'+date.getMinutes() : date.getMinutes()) + ':';
            var s = date.getSeconds() < 10 ?  '0'+date.getSeconds() : date.getSeconds() ;

            return Y+M+D+h+m+s
        }
    },
    computed: {
        ...mapGetters(['userId', 'name', 'deptName']),

    },

    methods: {
         // 多选框选中数据
         handleSelectionChange(selection) {
            console.log(selection)
            this.ids=selection
        },
        // geFileByBizlist() {
        //     geFileByBiz({ bizId: this.typeModel.inspectionId }).then((res) => {
        //         let onceTrialDoc = []
        //         let onceTrialMaterials = []
        //         let twiceTrialDoc=[]
        //         let twiceTrialMaterials=[]
        //         res.data.forEach((io) => {
        //             var index= io.originalFileName.lastIndexOf(".");
        //             var ext = io.originalFileName.substr(index+1);
        //             if (io.bizType === 'onceTrialDoc') {
        //                 onceTrialDoc.push(io)
        //                 this.typeModel.onceTrialDoc=ext
        //             }
        //             if (io.bizType === 'onceTrialMaterials') {
        //                 onceTrialMaterials.push(io)
        //                 this.typeModel.onceTrialMaterials=ext
        //             }
        //             if (io.bizType === 'twiceTrialDoc') {
        //                 twiceTrialDoc.push(io)
        //                 this.typeModel.twiceTrialDoc=ext
        //             }
        //             if (io.bizType === 'twiceTrialMaterials') {
        //                 twiceTrialMaterials.push(io)
        //                 this.typeModel.twiceTrialMaterials=ext
        //             }
        //         })

        //         this.onceTrialDocFile = onceTrialDoc
        //         this.onceTrialMaterialsFile = onceTrialMaterials
        //         this.twiceTrialDocFile = twiceTrialDoc
        //         this.twiceTrialMaterialsFile = twiceTrialMaterials
        //     })
        // },
        // picChange(fileList,type) {
        //     console.log(fileList,999)
        //     var filePath=fileList[0].name
        //     var index= filePath.lastIndexOf(".");
        //     var ext = filePath.substr(index+1);
        //     if (type=='onceTrialDoc') {
        //          this.typeModel.onceTrialDoc=ext
        //          this.$refs.typeModel.clearValidate('onceTrialDoc')
        //         // this.onceTrialDocFile=fileList
        //     } else if(type=='onceTrialMaterials'){
        //         this.$refs.typeModel.clearValidate('onceTrialMaterials')
        //           this.typeModel.onceTrialMaterials=ext
        //         // this.onceTrialMaterialsFile=fileList
        //     }else if(type=='twiceTrialDoc'){
        //         this.$refs.typeModel.clearValidate('twiceTrialDoc')
        //           this.typeModel.twiceTrialDoc=ext
        //         // this.twiceTrialDocFile=fileList
        //     }else if(type=='twiceTrialMaterials'){
        //         this.$refs.typeModel.clearValidate('twiceTrialMaterials')
        //           this.typeModel.twiceTrialMaterials=ext
        //         // this.twiceTrialMaterialsFile=fileList
        //     }
        //    this.$forceUpdate()
        // },

        fileChange(e) {
            this.fileList = e
            console.log(e)
        },

        handleQuery(){
            this.queryParams.pageNum = 1
            this.getList()
        },
        // // 查看
        // onInfo(row) {
        //     this.disabled=true
        //     this.typeModel=JSON.parse(JSON.stringify(row))
        //     // this.geFileByBizlist()

        //     this.typeOpen3 = true

        // },
         /**  按钮操作 */
        // handleAdd(row) {

        //     this.typeModel= {}
        //     this.typeModel=JSON.parse(JSON.stringify(row))
        //     this.geFileByBizlist()
        //     this.typeOpen = true

        // },
        // handleAdd2(row,type) {
        //     this.twotype=type

        //     this.typeModel= {}
        //     this.typeModel=JSON.parse(JSON.stringify(row))
        //     this.geFileByBizlist()
        //     this.typeOpen2 = true

        // },
        // close(){
        //     // this.typeModel= { }
        //     this.$refs.typeModel.resetFields();
        // },
        // // 删除
        // onDelete(row) {
        //     this.$modal.confirm('是否确认删除？').then(() => {
        //         skipDel(row.id).then((response) => {
        //             if (response.code == 200) {
        //                 this.$modal.msgSuccess('删除成功!')
        //                 this.getList()
        //             }
        //         })
        //     })
        // },

        // // 提交添加
        // submitAdd(){
        //     console.log(this.typeModel,'typeModel')
        //     this.$refs.typeModel.validate((valid) => {
        //         if (valid) {
        //             var data={
        //                 onceTrialResult:this.typeModel.onceTrialResult,
        //                 id:this.typeModel.id,
        //                 onceRemark:this.typeModel.onceRemark,
        //                 onceTrialDoc:this.typeModel.onceTrialDoc,

        //             }
        //             // 二次试投
        //             // if(this.typeModel.twiceTrial==1){
        //                 data.twiceTrialResult=this.typeModel.twiceTrialResult
        //                 // data.twiceTrialMaterials=this.typeModel.twiceTrialMaterials
        //                 data.twiceTrialDoc=this.typeModel.twiceTrialDoc
        //                 data.twiceRemark=this.typeModel.twiceRemark
        //             // }

        //             investmentapproveAPI(data).then(res=>{
        //                 this.$message.success( '审批成功')
        //                 this.getList()
        //                 this.typeOpen=false
        //                 this.typeOpen2=false
        //             })
        //         } else {
        //             // this.$modal.msgError('基本信息填写不完整!')

        //         }
        //     })
        // },

        /**  类型列表 */
        getList() {
            this.loading = true
            var data={
                ...this.queryParams,
                params:{
                    beginTime: this.queryParams.beginTime,
                    endTime: this.queryParams.endTime
                }
            }
            delete data.beginTime
            delete data.endTime
            listExtraCoaAPI(data).then((response) => {
                // if (response.code==200) {
                    this.incomingList = response.rows

                    this.total = response.total
                    this.loading = false

                // }
            })
        },
        // 取消按钮
        resetQuery() {

            this.queryParams={
                 pageNum:1,
                pageSize:20
            }
            this.getList()
        },

        /** 关闭操作 */
        handleClose(row) {
            this.$router.go(-1)
        },

    },
}
</script>
<style lang="scss" scoped>@import './index.scss';</style>
